﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cos.Core.Model.Common;
using Cos.Core.NHibernate.Tests;
using Cos.Module.Form.Data;
using Cos.Module.Form.Exceptions;
using NUnit.Framework;

namespace Cos.Module.Form.NHibernate.Test
{
    [TestFixture]
    public class FormRepositoryTest : InMemoryFixtureBase
    {
        public FormRepositoryTest()
            : base(new TestModel())
        {
        }

        protected IFormRepository repository;

        [TestFixtureSetUp]
        public void Init()
        {
            this.repository = new FormRepository(this.Session.SessionFactory);
        }

        [TestFixtureTearDown]
        public void Finish()
        {
        }

        [Test]
        [ExpectedException(typeof(FormNotFoundException))]
        public void GetForm1()
        {
            var formId = 1;
            Culture culture = null;
            var isLiveMode = true;

            this.repository.GetForm(formId, culture, isLiveMode);
        }

        [Test]
        [ExpectedException(typeof(FormNotFoundException))]
        public void GetForm2()
        {
            var formId = 1;
            var cultureId = 1;
            var isLiveMode = true;

            this.repository.GetForm(formId, cultureId, isLiveMode);
        }

        [Test]
        [ExpectedException(typeof(FormNotFoundException))]
        public void GetForm3()
        {
            var formId = 1;
            var cultureId = "fr-CA";
            var isLiveMode = true;

            this.repository.GetForm(formId, cultureId, isLiveMode);
        }

        [Test]
        public void GetAnswerCount()
        {
            Assert.AreEqual(0, this.repository.GetAnswerCount(1).Count);
        }

        [Test]
        [ExpectedException(typeof(InvalidOperationException))]
        public void SubmitForm()
        {
            this.repository.SubmitForm(null, true, string.Empty);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void CreateForm()
        {
            this.repository.CreateForm(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void UpdateForm()
        {
            this.repository.UpdateForm(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void DeleteForm()
        {
            this.repository.DeleteForm(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetPage()
        {
            this.repository.GetPage(0, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetPages()
        {
            this.repository.GetPages(0, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void CreatePage()
        {
            this.repository.CreatePage(null, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void UpdatePage()
        {
            this.repository.UpdatePage(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void DeletePage()
        {
            this.repository.DeletePage(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetElement()
        {
            this.repository.GetElement(0, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetElements()
        {
            this.repository.GetElements(0, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void CreateElement()
        {
            this.repository.CreateElement(null, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void UpdateElement()
        {
            this.repository.UpdateElement(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void DeleteElement()
        {
            this.repository.DeleteElement(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetChoice()
        {
            this.repository.GetChoice(0, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetChoices()
        {
            this.repository.GetChoices(0, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void CreateChoice()
        {
            this.repository.CreateChoice(null, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void UpdateChoice()
        {
            this.repository.UpdateChoice(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void DeleteChoice()
        {
            this.repository.DeleteChoice(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetSubmission()
        {
            this.repository.GetSubmission(0);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetSubmissions1()
        {
            this.repository.GetSubmissions(0);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetSubmissions2()
        {
            this.repository.GetSubmissions(0, null, null, null, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void CreateSubmission()
        {
            this.repository.CreateSubmission(0, null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void UpdateSubmission()
        {
            this.repository.UpdateSubmission(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetSubmissionValue()
        {
            this.repository.GetSubmissionValue(0);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetSumbissionValues()
        {
            this.repository.GetSubmissionValues(0);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void CreateSubmissionValue()
        {
            this.repository.CreateSubmissionValue(0);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void UpdateSubmissionValue()
        {
            this.repository.UpdateSubmissionValue(null);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetSubmissionValueItem()
        {
            this.repository.GetSubmissionValueItem(0);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void GetSubmissionValueItems()
        {
            this.repository.GetSubmissionValueItems(0);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void CreateSubmissionValueItem()
        {
            this.repository.CreateSubmissionValueItem(0);
        }

        [Test]
        [ExpectedException(typeof(System.NotImplementedException))]
        public void UpdateSubmissionValueItem()
        {
            this.repository.UpdateSubmissionValueItem(null);
        }
    }
}
